<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Models\Issue;

class VolumeController extends Controller
{
    public function list($type='years')
    {
        $issues = Issue::orderBy('year', 'desc')
            ->orderBy('volume', 'desc')
            ->orderBy('issue', 'desc')
            ->limit(6)
            ->get();


	   return view('volume.list', ['issues'=> $issues, 'type'=> $type]);
    }


    public function index($year)
    {
        $picIssues = Issue::orderBy('year', 'desc')
            ->orderBy('volume', 'desc')
            ->orderBy('issue', 'desc')
            ->limit(6)
            ->get();
        $issues = Issue::where('year', $year)
            ->orderBy('issue')
            ->get();

    	return view('volume.index', [
            'issues' => $issues,
            'pic_issues' => $picIssues
        ]);
    }
}
